/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.navid.trafalgar.model.opengl2;

import com.jme3.asset.AssetManager;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.navid.trafalgar.model.IWind;
import com.navid.trafalgar.model.ArrowModel;

/**
 *
 * @author alberto
 */
public final class RotateSimpleWind implements IWind{
    
    ArrowModel arrowModel;
    Vector2f vector = new Vector2f(1,0);
    
    public RotateSimpleWind(AssetManager assetManager){
        arrowModel = new ArrowModel(assetManager, new Vector3f(1,0,0));
        setWind(new Vector2f(1, 0));
    }
    
    public Geometry getGeometry(){
        return arrowModel;
    }
    
    public void rotateWind(float angle){
        vector.rotateAroundOrigin(angle, false);
        arrowModel.rotate(0, -angle, 0);
    }

    public Vector2f getWind() {
        return vector;
    }

    public void increase(float value) {
        vector.multLocal(value);
        arrowModel.scale(value);
    }

    void setWind(Vector2f newVector) {
        Vector2f oldVector = this.vector;
        this.vector = newVector;
        
        arrowModel.rotate(0, newVector.angleBetween(oldVector), 0);
        arrowModel.scale(newVector.length()/oldVector.length());
    }
    
}
